<include file="Public/min-header" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<style>
	  #fenlei_box{border: 1px solid #3297ff;position: absolute;width:450px;height:250px;overflow:hidden; z-index:9999;background:#fff;display:none;}
	  #fenlei_box li{list-style: none;color:#3297ff;text-align:left;margin-left:-20px;line-height: 32px;cursor: pointer;border-bottom:1px dashed}
	  #teshu{display: none;color:red;}
	  /* 自定义进度条样式 */
  progress {
    width: 100%;
    height: 20px;
    color: #555;
    background-color: #eee;
    border: none;
    border-radius: 3px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2) inset;
  }
 
  /* 已完成部分的样式 */
  progress::-webkit-progress-value {
    background-color: #2ecc71;
  }
 
  /* 未完成部分的样式 */
  progress::-webkit-progress-bar {
    background-color: #eee;
  }
</style>

 <style>
        * {
            margin: 0;
            padding: 0;
        }
 
        li {
            list-style-type: none;
        }
 
        .tab {
            width: 100%;
            /*margin: 100px auto;*/
        }
 
        .tab_list {
            height: 39px;
            border: 1px solid #ccc;
            background-color: #f1f1f1;
        }
 
        .tab_list li {
            float: left;
            height: 39px;
            line-height: 39px;
            padding: 0 20px;
            text-align: center;
            cursor: pointer;
        }
 
        .tab_list .current {
            background-color: #c81623;
            color: #fff;
        }
 
        .item_info {
            padding: 20px 0 0 20px;
        }
 
        .item {
            display: none;
        }
    </style>
<div class="wrapper">
	<include file="Public/breadcrumb"/>
	<section class="content">
       <div class="row">
       		<div class="col-xs-12">
	       		<div class="box">
	             <div class="box-header">
	               	<nav class="navbar navbar-default">	     
				        <div class="collapse navbar-collapse">
				          <form class="navbar-form form-inline" id="form" action="{:U('Crm/planList')}" method="get">
				            <div class="form-group">
				              	<input type="text" name="user_name" id="user_name" class="form-control" value="{:I('user_name')}" placeholder="请输入业务员名称/手机号码" oninput="user_sousuo($(this))" autocomplete="off">
				              	<ul id="fenlei_box">
                                </ul>
                                <input type="hidden" name="user_id" id="user_id" value="{:I('user_id')}"/>
				            </div>
				            <div class="form-group">
                      <!--              <div class="input-group">-->
                      <!--                  <input type="text" name="timegap" value="{$timegap}" placeholder="日期"  id="add_time" class="input-sm" style="width: 220px;">-->
					                 <!--</div>-->
                                </div>
                                <input type="hidden" id="extraParam" name="extraParam" value="{$type}">  
				            <button type="submit" class="btn btn-primary">查询</button>
				            <div class="form-group pull-right">
					            <a href="{:U('Crm/addplan')}" class="btn btn-primary pull-right"><i class="fa fa-plus"></i> 新增任务</a>
				            </div>	
				            
				          </form>
				      	</div>
	    			</nav>
	             </div>
	              <div class="tab">
                    <div class="tab_list">
                        <ul>
                            <li id="tab1" <if condition="$type eq 0">class="current"</if> >全部</li>
                            <li id="tab2" <if condition="$type eq 2">class="current"</if>>未完成</li>
                            <li id="tab3" <if condition="$type eq 1">class="current"</if>>已完成</li>
                        </ul>
                    </div>
                    <div class="tab_con">
                        <div class="item" style="display: block;">
                            <div class="box-body">
    	           	 <div class="row">
    	            	<div class="col-sm-12">
    		              <table id="list-table" class="table table-bordered table-striped dataTable">
    		                 <thead>
    		                   <tr role="row">
                                    <th>id</th>
                                    <th>姓名</th>
    			                   <th>业绩时间</th>
    			                   <th>业绩</th>
    			                   <th>待完成业绩</th>
    			                   <th>已完成业绩</th>
    			                   <th>完成进度</th>
    			                   <th>剩余天数</th>
    			                   <th>服务客户</th>
    			                   <th>查看拜访详情</th>
    			                   <th>状态</th>
    		                  	   <th>操作</th>
    		                   </tr>
    		                 </thead>
    						<tbody>
                              <foreach name="list" item="vo" key="k" >
                                 <tr role="row"
    		                     <?php
    		                        if($vo['days'] < 7){
    		                     ?>
    		                     style="color:red"
    		                     <?php
                    				}
                    			 ?>
                    			>  
                                 <td>{$vo.id}</td>
    		                     <td>{$vo.company}</td>	                    
    		                     <td>{$vo.time}</td>
    		                     <td>{$vo.amount}元</td>
    		                     <?php
    		                        if($vo['status'] == "进行中"){
    		                     ?>
    		                        <td style="color:#FFA500">{$vo.tobedone}元</td>
    		                     <?php
                    				}elseif($vo['status'] == "未完成"){
                    			 ?>
                    			    <td style="color:red">{$vo.tobedone}元</td>
    		                     <?php
                    				}else{
                    			 ?>
                    			    <td>{$vo.tobedone}元</td>
                    			  <?php
                    				}
                    			 ?>
                    			 <td>{$vo.total}元</td>
    		                     <td><progress value="{$vo.progress}" max="100" title="{$vo.per}"> </progress></td>
    		                     <td>{$vo.days}</td>
    		                     <td> 
    		                     <!--  <a href="{:U('Admin/crm/customdetail',array('id'=>$vo['id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="查看客户"><i class="fa fa-eye"></i></a> -->
    		                       <a class="btn btn-primary" data-url="{:U('Admin/crm/customdetail',array('id'=>$vo['id']))}" href="javascript:;" onclick="go_class_info(this,'查看客户')"  data-original-title="查看客户"><i class="fa fa-eye"></i></a>
    		                     </td>
    							    <td> 
    							    <!-- <a href="{:U('Admin/crm/visitList',array('user_id'=>$vo['user_id'],'timegap'=>$vo['timegap']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="查看拜访计划"><i class="fa fa-eye"></i></a>-->
    							    <a class="btn btn-primary" data-url="{:U('Admin/crm/visitList',array('user_id'=>$vo['user_id'],'timegap'=>$vo['timegap']))}" href="javascript:;" onclick="go_class_info(this,'查看拜访计')"  data-original-title="查看拜访计划"><i class="fa fa-eye"></i></a>
    							    </td>
    							 <td>{$vo.status}</td>
    		                     <td>
    		                       <a class="btn btn-primary" href="{:U('Crm/addplan',array('act'=>'edit','id'=>$vo['id']))}"><i class="fa fa-pencil"></i></a>
    		                      <a class="btn btn-danger" onclick="delfunc(this)" data-url="{:U('Crm/delplan')}" data-id="{$vo.id}"><i class="fa fa-trash-o"></i></a>
    				     </td>
    		                   </tr>
    		                  </foreach>
    		                   </tbody>
    		                 <tfoot>
    		                 
    		                 </tfoot>
    		               </table>
    	               </div>
    	          </div>
                  <div class="row">
                  	    <div class="col-sm-6 text-left">
                  	    	<button class="btn btn-default btn-sm checkbox-toggle"><i class="fa fa-square-o"></i></button>
                  	    </div>
                        <div class="col-sm-6 text-right">{$page}</div>		
                  </div>
	          </div>
                        </div>
                        <div class="item">
                            <div class="box-body">
    	           	 <div class="row">
    	            	<div class="col-sm-12">
    		              <table id="list-table" class="table table-bordered table-striped dataTable">
    		                 <thead>
    		                   <tr role="row">
                                    <th>id</th>
                                    <th>姓名</th>
    			                   <th>业绩时间</th>	
    			                   <th>业绩</th>
    			                   <th>待完成业绩</th>
    			                   <th>已完成业绩</th>
    			                   <th>完成进度</th>
    			                   <th>剩余天数</th>
    			                   <th>服务客户</th>
    			                   <th>查看拜访详情</th>
    			                   <th>状态</th>
    		                  	   <th>操作</th>
    		                   </tr>
    		                 </thead>
    						<tbody>
                              <foreach name="list" item="vo" key="k" >
                                <tr role="row"
    		                     <?php
    		                        if($vo['days'] < 7){
    		                     ?>
    		                     style="color:red"
    		                     <?php
                    				}
                    			 ?>
                    			>  
                                 <td>{$vo.id}</td>
    		                     <td>{$vo.company}</td>	                    
    		                     <td>{$vo.time}</td>
    		                      <td>{$vo.amount}元</td>
    		                     <td  style="color:red">{$vo.tobedone}元</td>
    		                     <td>{$vo.total}元</td>
    		                     <td><progress value="{$vo.progress}" max="100" title="{$vo.per}"> </progress></td>
    		                     <td>{$vo.days}</td>
    		                     <td> 
    		                     <!--  <a href="{:U('Admin/crm/customdetail',array('id'=>$vo['id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="查看客户"><i class="fa fa-eye"></i></a> -->
    		                       <a class="btn btn-primary" data-url="{:U('Admin/crm/customdetail',array('id'=>$vo['id']))}" href="javascript:;" onclick="go_class_info(this,'查看客户')"  data-original-title="查看客户"><i class="fa fa-eye"></i></a>
    		                     </td>
    							    <td> 
    							    <!-- <a href="{:U('Admin/crm/visitList',array('user_id'=>$vo['user_id'],'timegap'=>$vo['timegap']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="查看拜访计划"><i class="fa fa-eye"></i></a>-->
    							    <a class="btn btn-primary" data-url="{:U('Admin/crm/visitList',array('user_id'=>$vo['user_id'],'timegap'=>$vo['timegap']))}" href="javascript:;" onclick="go_class_info(this,'查看拜访计')"  data-original-title="查看拜访计划"><i class="fa fa-eye"></i></a>
    							    </td>
								<td>{$vo.status}</td>
    		                     <td>
    		                       <a class="btn btn-primary" href="{:U('Crm/addplan',array('act'=>'edit','id'=>$vo['id']))}"><i class="fa fa-pencil"></i></a>
    		                      <a class="btn btn-danger" onclick="delfunc(this)" data-url="{:U('Crm/delplan')}" data-id="{$vo.id}"><i class="fa fa-trash-o"></i></a>
    				     </td>
    		                   </tr>
    		                  </foreach>
    		                   </tbody>
    		                 <tfoot>
    		                 
    		                 </tfoot>
    		               </table>
    	               </div>
    	          </div>
                  <div class="row">
                  	    <div class="col-sm-6 text-left">
                  	    	<button class="btn btn-default btn-sm checkbox-toggle"><i class="fa fa-square-o"></i></button>
                  	    </div>
                        <div class="col-sm-6 text-right">{$page}</div>		
                  </div>
	          </div>
                        </div>
                        <div class="item">
                            <div class="box-body">
    	           	 <div class="row">
    	            	<div class="col-sm-12">
    		              <table id="list-table" class="table table-bordered table-striped dataTable">
    		                 <thead>
    		                   <tr role="row">
                                    <th>id</th>
                                    <th>姓名</th>
    			                   <th>业绩时间</th>	
    			                   <th>业绩</th>
    			                   <th>待完成业绩</th>
    			                   <th>已完成业绩</th>
    			                   <th>完成进度</th>
    			                   <th>剩余天数</th>
    			                   <th>服务客户</th>
    			                   <th>查看拜访详情</th>
    			                   <th>状态</th>
    		                  	   <th>操作</th>
    		                   </tr>
    		                 </thead>
    						<tbody>
                              <foreach name="list" item="vo" key="k" >
                                 <tr role="row"
    		                     <?php
    		                        if($vo['days'] < 7){
    		                     ?>
    		                     style="color:red"
    		                     <?php
                    				}
                    			 ?>
                    			>    
                                 <td>{$vo.id}</td>
    		                     <td>{$vo.company}</td>	                    
    		                     <td>{$vo.time}</td>
    		                      <td>{$vo.amount}元</td>
    		                     <td>{$vo.tobedone}元</td>
    		                     <td>{$vo.total}元</td>
    		                     <td><progress value="{$vo.progress}" max="100" title="{$vo.per}"> </progress></td>
    		                     <td>{$vo.days}</td>
    		                     <td> 
    		                     <!--  <a href="{:U('Admin/crm/customdetail',array('id'=>$vo['id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="查看客户"><i class="fa fa-eye"></i></a> -->
    		                       <a class="btn btn-primary" data-url="{:U('Admin/crm/customdetail',array('id'=>$vo['id']))}" href="javascript:;" onclick="go_class_info(this,'查看客户')"  data-original-title="查看客户"><i class="fa fa-eye"></i></a>
    		                     </td>
    							    <td> 
    							    <!-- <a href="{:U('Admin/crm/visitList',array('user_id'=>$vo['user_id'],'timegap'=>$vo['timegap']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="查看拜访计划"><i class="fa fa-eye"></i></a>-->
    							    <a class="btn btn-primary" data-url="{:U('Admin/crm/visitList',array('user_id'=>$vo['user_id'],'timegap'=>$vo['timegap']))}" href="javascript:;" onclick="go_class_info(this,'查看拜访计')"  data-original-title="查看拜访计划"><i class="fa fa-eye"></i></a>
    							    </td>
								 <td>{$vo.status}</td>
    		                     <td>
    		                       <a class="btn btn-primary" href="{:U('Crm/addplan',array('act'=>'edit','id'=>$vo['id']))}"><i class="fa fa-pencil"></i></a>
    		                      <a class="btn btn-danger" onclick="delfunc(this)" data-url="{:U('Crm/delplan')}" data-id="{$vo.id}"><i class="fa fa-trash-o"></i></a>
    				     </td>
    		                   </tr>
    		                  </foreach>
    		                   </tbody>
    		                 <tfoot>
    		                 
    		                 </tfoot>
    		               </table>
    	               </div>
    	          </div>
                  <div class="row">
                  	    <div class="col-sm-6 text-left">
                  	    	<button class="btn btn-default btn-sm checkbox-toggle"><i class="fa fa-square-o"></i></button>
                  	    </div>
                        <div class="col-sm-6 text-right">{$page}</div>		
                  </div>
	          </div>
                        </div>
                    </div>
                </div>
	        </div>
       	</div>
       </div>
   </section>
<script>
$(document).ready(function(){
	$('#add_time').daterangepicker({
		format:"YYYY-MM-DD HH:mm",
		singleDatePicker: false,
		showDropdowns: true,
		minDate:'2021-01-01 00:00',
		maxDate:'2030-01-01 00:00',
		startDate:'{:date("Y-m-d")} 00:00',
        showWeekNumbers: true,
        timePicker: true,
        timePickerIncrement: 1,
        timePicker12Hour: false,
        opens: 'right',
        buttonClasses: ['btn btn-default'],
        applyClass: 'btn-small btn-primary',
        cancelClass: 'btn-small',
	    locale : {
            applyLabel : '确定',
            cancelLabel : '取消',
            fromLabel : '起始时间',
            toLabel : '结束时间',
            customRangeLabel : '自定义',
            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
            firstDay : 1
        }
	});

	$("body").on("click", function() {
		$('#fenlei_box').hide(100);
	});
	$("#fenlei_box").on("click","li", function() {
		var user_id=$(this).attr('rel'),
		company=$(this).attr('title');

		$('#user_name').val(company);
		$('#user_id').val(user_id);
	});
})

	function user_sousuo(obj)
	{
	    var value = obj.val();
		if($.trim(user_name) == '')
			return false;
		
		var dai_type=$("input[type='radio']:checked").val();
	    $.ajax({
	       type : "POST",
	       url:"/index.php?m=admin&c=crm&a=search_user",//+tab,
	       data :{search_key:value},
	        success: function(data){
				data=JSON.parse(data);
					 if(data.code=='200'){
						$('#fenlei_box').show(200);
						$('#add_user').hide(100);
						$('#fenlei_box').html(data.selects);
					 }else{
						$('#fenlei_box').hide(100);
						if(dai_type==1)
						$('#add_user').show(200);
						
						$('#fenlei_box').html('');
					 }
	        }
	    });
	}
  
$("#daochu").click(function(){
	var user_id=$("#user_id").val(),
	user_name=$("#user_name").val(),
	visit_name=$("#visit_name").val(),
    timegap=$("#timegap").val();
	location.href='/index.php/Admin/crm/export_user?user_id='+user_id+'&user_name='+user_name+'&timegap='+timegap+'&visit_name='+visit_name;
});
</script>
<script>
        // 获取元素
        var tab_list = document.querySelector('.tab_list');
        var lis = tab_list.querySelectorAll('li');
        var items = document.querySelectorAll('.item');
        var types = document.getElementById('extraParam').value;
 
        // for循环绑定点击事件
        for (var i = 0; i < lis.length; i++) {
            lis[i].setAttribute('index', i);
 
            lis[i].onclick = function () {
                for (var i = 0; i < lis.length; i++) {
                    lis[i].className = '';
                }

                //this.className = 'current';
                if(types == 0){
                    document.getElementById('tab1').className = 'current';
                }else if(types == 1){
                    document.getElementById('tab2').className = 'current';
                }else{
                    document.getElementById('tab3').className = 'current';
                }
                var index = this.getAttribute('index');

                for (var i = 0; i < items.length; i++) {
                    items[i].style.display = 'none';
                }

                items[index].style.display = 'block';
                var form = document.getElementById('form');
                var extraInput  = document.getElementById('extraParam');
                console.log(this.id);
                if(this.id == 'tab1'){     
                     extraInput.value = '0';
                }else if(this.id == 'tab2'){     
                     extraInput.value = '2';
                }else if(this.id == 'tab3'){     
                     extraInput.value = '1';
                }
               form.submit();
            }
        }
        
        function go_class_info(o){
        	var url = $(o).attr('data-url');
        	layer.open({
        		type: 2,
        		title: '查看客户',
        		shadeClose: true,
        		shade: 0.2,
        		area: ['60%', '90%'],
        		content: url,
        	});
        }
    </script>

</div>
</body>
</html>   
